<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="./js/react.development.js"></script>
  <script src="./js/react-dom.development.js"></script>
  <script src="./js/babel.min.js"></script>
</head>
<body>
  <div id="root"></div>

  <script type="text/babel">
    /* 
    React在渲染数组时, 会自动遍历每个item依次渲染显示
    */
    const courses = [
      {id: 1, name: 'React'},
      {id: 3, name: 'Vue'},
      {id: 5, name: '小程序'},
      {id: 6, name: 'xxx'}
    ]

    const vDom = (
      <div>
        <h1>前端框架课程列表</h1>  
        <ul>
          {
            [
              <li key={courses[0].id}>{courses[0].name}</li>,
              <li key={courses[1].id}>{courses[1].name}</li>,
              <li key={courses[2].id}>{courses[2].name}</li>,
              <li key={courses[3].id}>{courses[3].name}</li>,
            ]
          }
        </ul>
      </div>
    ) 

    // () => {} // 箭头函数的箭头要有return的作用必须保证后面不要紧跟着{}
    
    
    ReactDOM.render(vDom, document.getElementById('root'))
  </script>
</body>
</html>